/*
    5. Write a program in C to Find the Number of Lines in a Text File.
    Test Data :
    Input the file name to be opened : test.txt
    Expected Output :

    The lines in the file test.txt are : 4
*/

#include <stdio.h>

int main(void)
{
    FILE *fp;
    int lines = 0;
    char filename[64];
    char ch;
    printf("Input the file name to be opened : ");
    scanf("%s", filename);
    fp = fopen(filename, "r");
    while((ch = fgetc(fp)) != EOF){
        if(ch == '\n'){
            lines++;
        }
    }
    printf("\nThe lines in the file %s are : %d", filename, lines);

    return 0;
}